package cn.edu.cuit.aumalls.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.github.pagehelper.PageInfo;

import cn.edu.cuit.aumalls.constant.PageConstant;
import cn.edu.cuit.aumalls.entity.Goods;
import cn.edu.cuit.aumalls.entity.GoodsType;
import cn.edu.cuit.aumalls.service.GoodsService;
import cn.edu.cuit.aumalls.service.GoodsTypeService;

@Controller
public class ShowListController {

	@Autowired
	private GoodsService goodsService;
	@Autowired
	private GoodsTypeService goodsTypeService;
	
	
	
	@RequestMapping("/showList")
	public String showgoods(Model model,@RequestParam(value="pageNum"
			,required=false,defaultValue="1")int pageNum) {
		
		PageInfo<Goods> goods = goodsService.showAll(pageNum,PageConstant.PAGE_SIZE);
		List<GoodsType> goodsType = goodsTypeService.showlv1(); //商品大类型
		List<GoodsType> allGoodsType = goodsTypeService.showAll(); //显示全部商品种类
		System.out.println(goodsType);
		System.out.println(goods);
		System.out.println(allGoodsType);
		model.addAttribute("list", goods);
		model.addAttribute("goodsType", goodsType);
		model.addAttribute("allGoodsType", allGoodsType);
		
		return "showlist";
	}
}
